package com.easidea.tim.dao.customer;

import java.util.List;

import org.hibernate.Criteria;
import org.springside.core.dao.extend.HibernateEntityExtendDao;

import com.easidea.tim.entity.customer.Customer;
import com.easidea.tim.util.ParamsUtilities;

public class CustomerDao extends HibernateEntityExtendDao<Customer> {
 
	@SuppressWarnings("unchecked")
	public List<Customer> GetAllCustomer(){
		Criteria ca = createUnDeletedCriteria();
		return ca.list();
	}
	@SuppressWarnings("unchecked")
	public List<Customer> filterCustomerByName(String name) {

			String hql = "select new com.easidea.tim.entity.customer.Customer(c.id,c.name,c.bizTel1,c.bizTel2,c.contactor )"
				 + " from " + Customer.class.getName() 
				 + " as c where c.deleted = 0 and c.name like '" + ParamsUtilities.dealWithReservedSqlChar(name) + "%'";
			return this.getHibernateTemplate().find(hql);		
		
	}
}
